﻿using System.Collections;
using System.Collections.Generic;
using Data;
using UnityEngine;
using UnityEngine.UI;
using ZM.RedDotSystem;

public class RedDotNodeNumTaskDemo : MonoBehaviour
{
    public GameObject taskWindow;
    public Button taskButton;

    public Button box1Button;
    public Button box2Button;
    public Button box3Button;
    // public Button box3_1Button;
    // public Button box3_2Button;
    //
    // public Button box3_1_1Button;
    // public Button box3_1_2Button;

    public Button taskCloseButton;

    void Awake()
    {
        taskButton.onClick.AddListener(OnTaskButtonClick);
        box1Button.onClick.AddListener(OnBox1TabButtonClick);
        box2Button.onClick.AddListener(OnBox2TabButtonClick);
        box3Button.onClick.AddListener(OnBox3TabButtonClick);
        // box3_1Button.onClick.AddListener(OnBox3_1TabButtonClick);
        // box3_2Button.onClick.AddListener(OnBox3_2TabButtonClick);
        //
        // box3_1_1Button.onClick.AddListener(OnBox3_1_1TabButtonClick);
        // box3_1_2Button.onClick.AddListener(OnBox3_1_2TabButtonClick);

        taskCloseButton.onClick.AddListener(OnTaskCloseButtonClick);

        RedDotTreeNode taskmainRoot = new RedDotTreeNode
        {
            node = RedDotDefine.TaskRoot,
            redDotType = RedDotType.RedDotNodeNum
        };
        RedDot_TaskBox1 task_box1 = new RedDot_TaskBox1
        {
            parentNode = RedDotDefine.TaskRoot,
            node = RedDotDefine.Task_Box1
        };
        RedDot_TaskBox2 task_box2 = new RedDot_TaskBox2
        {
            parentNode = RedDotDefine.TaskRoot,
            node = RedDotDefine.Task_Box2
        };
        //宝箱3 异节点数
        RedDot_TaskBox3 task_box3 = new RedDot_TaskBox3
        {
            parentNode = RedDotDefine.TaskRoot,
            node = RedDotDefine.Task_Box3,
            // redDotType = RedDotType.RedDotNodeNum
        };
        RedDot_TaskBox3_1 task_box3_1 = new RedDot_TaskBox3_1
        {
            parentNode = RedDotDefine.Task_Box3,
            node = RedDotDefine.Task_Box3_1,
            redDotType = RedDotType.RedDotNodeNum
        };
        // RedDot_TaskBox3_2 task_box3_2 = new RedDot_TaskBox3_2
        // {
        //     parentNode = RedDotDefine.Task_Box3,
        //     node = RedDotDefine.Task_Box3_2
        // };
        //
        // RedDot_TaskBox3_1_1 task_box3_1_1 = new RedDot_TaskBox3_1_1
        // {
        //     parentNode = RedDotDefine.Task_Box3_1,
        //     node = RedDotDefine.Task_Box3_1_1
        // };
        // RedDot_TaskBox3_1_2 task_box3_1_2 = new RedDot_TaskBox3_1_2
        // {
        //     parentNode = RedDotDefine.Task_Box3_1,
        //     node = RedDotDefine.Task_Box3_1_2
        // };


        RedDotSystem.Instance.InitlizateRedDotTree(new List<RedDotTreeNode>
        {
            taskmainRoot,
            task_box1,
            task_box2,
            task_box3,
            task_box3_1,
            // task_box3_2,
            // task_box3_1_1,
            // task_box3_1_2
        });
    }

    #region 按钮事件

    public void OnTaskButtonClick()
    {
        taskWindow.SetActive(true);
    }
    public void OnBox1TabButtonClick()
    {
        RedDotDataMgr.Task_Box1_isRead = true;
        RedDotSystem.Instance.UpdateRedDotState(RedDotDefine.Task_Box1);
    }
    public void OnBox2TabButtonClick()
    {
        RedDotDataMgr.Task_Box2_isRead = true;
        RedDotSystem.Instance.UpdateRedDotState(RedDotDefine.Task_Box2);
    }
    public void OnBox3TabButtonClick()
    {
        RedDotDataMgr.Task_Box3_isRead = true;
        RedDotSystem.Instance.UpdateRedDotState(RedDotDefine.Task_Box3);
    }
    public void OnBox3_1TabButtonClick()
    {
        RedDotDataMgr.Task_Box3_1_isRead = true;
        RedDotSystem.Instance.UpdateRedDotState(RedDotDefine.Task_Box3_1);
    }
    public void OnBox3_2TabButtonClick()
    {
        RedDotDataMgr.Task_Box3_2_isRead = true;
        RedDotSystem.Instance.UpdateRedDotState(RedDotDefine.Task_Box3_2);
    }

    public void OnBox3_1_1TabButtonClick()
    {
        RedDotDataMgr.Task_Box3_1_1_isRead = true;
        RedDotSystem.Instance.UpdateRedDotState(RedDotDefine.Task_Box3_1);
    }
    public void OnBox3_1_2TabButtonClick()
    {
        RedDotDataMgr.Task_Box3_1_2_isRead = true;
        RedDotSystem.Instance.UpdateRedDotState(RedDotDefine.Task_Box3_2);
    }

    public void OnTaskCloseButtonClick()
    {
        taskWindow.SetActive(false);
    }

    #endregion

}